import { $axios } from "../http/http";

// 登录请求
export const login = (data) => {
  return $axios({
    url: `/api/login`,
    method: 'post',
    data
  })
}

// 获取列表tab
export const getListTab = () => {
  return $axios({
    url: `/my/article/cates`,
    method: 'get',
  })
}

// 获取列表数据
export const getListData = (params) => {
  return $axios({
    url: `/my/article/list`,
    method: 'get',
    params
  })
}

// 获取用户信息
export const getUserData = () => {
  return $axios({
    url: `/my/userinfo`,
    method: 'get',
  })
}

// 获取用户修改页信息
export const getUserEdit = () => {
  return $axios({
    url: `/v1_0/user/profile`,
    method: 'get'
  })
}

// 修改头像的请求
export const updateUserProfile = (data) => {
  return $axios({
    url: `/v1_0/user/photo`,
    method: 'patch',
    data
  })
}

// 修改名字和生日的请求
export const setNameBirthday = (data) => {
  return $axios({
    url: `/v1_0/user/profile`,
    method: 'patch',
    data
  })
}

// 获取文章的详情数据
export const getArticleDetail = (params) => {
  return $axios({
    url: `/my/article/${params.id}`,
    method: 'get'
  })
}

// 关注作者请求
export const setFollow = (data) => {
  return $axios({
    url: `/v1_0/user/followings`,
    method: 'post',
    data
  })
}

// 取消关注请求
export const cancelFollow = (author_id) => {
  return $axios({
    url: `/v1_0/user/followings/${author_id}`,
    method: 'delete'
  })
}

// 点赞文章请求
export const setLike = (data) => {
  return $axios({
    url: `/v1_0/article/likings`,
    method: 'post',
    data
  })
}

// 取消点赞请求
export const deleteLike = (data) => {
  return $axios({
    url: `/v1_0/article/likings/${data.article_id}`,
    method: 'delete'
  })
}

// 获取文章下评论数据
export const getCmtList = (params) => {
  return $axios({
    url: `/v1_0/comments`,
    method: 'get',
    params
  })
}

// 评论点赞的请求
export const addLikeCmt = (data) => {
  return $axios({
    url: `/v1_0/comment/likings`,
    method: 'post',
    data
  })
}

// 取消评论点赞
export const delLikeCmt = (cmt_id) => {
  return $axios({
    url: `/v1_0/comment/likings/${cmt_id}`,
    method: 'delete',
  })
}

// 发布评论
export const pubComment = (data) => {
  return $axios({
    url: `/v1_0/comments`,
    method: 'post',
    data
  })
}

// 获取所有频道列表数据
export const getAllListTab = (params) => {
  return $axios({
    url: `/my/article/cates`,
    method: 'get',
    params
  })
}

// 更新用户所选的频道数据
export const updateUserListTab = (data) => {
  return $axios({
    url: `/v1_0/user/channels`,
    method: 'put',
    data
  })
}

// 搜索
export const getSuggestList = (params) => {
  return $axios({
    url: `/v1_0/suggestion`,
    method: 'get',
    params
  })
}

// 获取搜索文章的数据
export const getSearchResult = (params) => {
  return $axios({
    url: `/v1_0/search`,
    method: 'get',
    params
  })
}

// 将文章设为不感兴趣
export const dislikeArticle = (data) => {
  return $axios({
    url: `/v1_0/article/dislikes`,
    method: 'post',
    data
  })
}

// 举报文章
export const reportArticle = (data) => {
  return $axios({
    url: `/v1_0/article/reports`,
    method: 'post',
    data
  })
}